package com.example.kaoqinmanager.activity;

import androidx.recyclerview.widget.LinearLayoutManager;

import android.os.Bundle;
import android.view.MenuItem;

import com.example.kaoqinmanager.adapter.BulletinAdapter;
import com.example.kaoqinmanager.base.BaseBindingActivity;
import com.example.kaoqinmanager.bean.BulletinBean;
import com.example.kaoqinmanager.databinding.ActivityBulletinBinding;

import java.util.ArrayList;
import java.util.List;

public class BulletinActivity extends BaseBindingActivity<ActivityBulletinBinding> {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        actionBar.setTitle("公告");
        //显示返回箭头默认是不显示的
        actionBar.setDisplayHomeAsUpEnabled(true);


        List<BulletinBean> list = new ArrayList<>();
        BulletinBean bean2 = new BulletinBean();
        bean2.setTvTitle("天气公告");
        bean2.setTvName("今日有雾，小心慢行，点击查看推荐出行路线");
        bean2.setTvTime("2021-12-16");
        list.add(bean2);

        BulletinBean bean3 = new BulletinBean();
        bean3.setTvTitle("打卡公告");
        bean3.setTvName("今日您有未打卡的记录，点击查看详情");
        bean3.setTvTime("2021-12-15");
        list.add(bean3);


        BulletinBean bean4 = new BulletinBean();
        bean4.setTvTitle("统计公告");
        bean4.setTvName("以为您生成本月打卡统计，点击查看详情");
        bean4.setTvTime("2021-12-14");
        list.add(bean4);

        BulletinBean bean5 = new BulletinBean();
        bean5.setTvTitle("公告");
        bean5.setTvName("今天天气良好，多多户外活动哦！");
        bean5.setTvTime("2021-12-13");
        list.add(bean5);


        for (int i = 0; i < 10; i++) {
            BulletinBean bean = new BulletinBean();
            bean.setTvTitle("天气公告");
            bean.setTvName("今日有雾，小心慢行，点击查看推荐出行路线");
            bean.setTvTime("2021-12-08");
            list.add(bean);
        }

        BulletinAdapter recordAdapter = new BulletinAdapter(this, list);
        getBinding().mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        getBinding().mRecyclerView.setAdapter(recordAdapter);


    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            //actionbar的左侧图标的点击事件处理
            case android.R.id.home:
                finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

}

